<template>
  <view class="monitor-card">
    <view class="card-header">
      <text class="card-title">{{ title }}</text>
      <view class="status-tag" :class="statusClass">
        <text>{{ status }}</text>
      </view>
    </view>
    <view class="card-body">


      <slot name="custom-slot">
        <text class="value">{{ value }}</text>
        <text class="unit">{{ unit }}</text>

      </slot>

    </view>
    <view v-if="trend" class="trend">
      <uni-icons :type="trend.type === 'up' ? 'arrow-up' : 'arrow-down'"
        :color="trend.type === 'up' ? '#f56c6c' : '#67c23a'" size="14"></uni-icons>
      <text class="trend-text">{{ trend.text }}</text>
    </view>
    <view v-if="footerText || footerButton" class="card-footer">
      <text v-if="footerText" class="status-text">{{ footerText }}</text>
      <button v-if="footerButton" class="history-btn" @click="footerButton.action">{{ footerButton.label }}</button>
    </view>
  </view>
</template>

<script setup>
import { computed } from 'vue'

defineProps({
  title: String, // 卡片标题
  status: String, // 状态文本
  statusClass: String, // 状态样式类
  value: [String, Number], // 主显示值
  unit: String, // 单位
  trend: Object, // 趋势信息 { type: 'up' | 'down', text: '较昨日 10%' }
  footerText: String, // 底部文本
  footerButton: Object, // 底部按钮 { label: '历史记录', action: () => {} }

})
</script>

<style scoped>
.monitor-card {
  background-color: #fff;
  border-radius: 16rpx;
  padding: 30rpx;
  box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.05);
  margin-bottom: 24rpx;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20rpx;
}

.card-title {
  font-size: 32rpx;
  font-weight: 500;
  color: #333;
}

.status-tag {
  padding: 6rpx 16rpx;
  border-radius: 20rpx;
  font-size: 24rpx;
}

.status-tag.success {
  background-color: #f0f9eb;
  color: #67c23a;
}

.status-tag.warning {
  background-color: #fdf6ec;
  color: #e6a23c;
}

.status-tag.error {
  background-color: #fef0f0;
  color: #f56c6c;
}

.card-body {
  display: flex;
  align-items: flex-end;
  margin: 30rpx 0;
}

.value {
  font-size: 60rpx;
  font-weight: bold;
  color: #333;
  margin-right: 10rpx;
}

.unit {
  font-size: 28rpx;
  color: #999;
  margin-bottom: 10rpx;
}

.trend {
  display: flex;
  align-items: center;
}

.trend-text {
  font-size: 26rpx;
  color: #666;
  margin-left: 8rpx;
}

.card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 20rpx;
  border-top: 1rpx solid #f0f0f0;
}

.status-text {
  font-size: 26rpx;
  color: #666;
}

.history-btn {
  font-size: 26rpx;
  color: #409eff;
  background: none;
  padding: 0;
}
</style>